@extends('layout.base')
@extends('layout')
@section('content')
@section('contenido')
@stop
   <style> 
.modal-header-danger {
  color:#fff;
    padding:9px 15px;
    border-bottom:1px solid #eee;
    background-color: #00ccff;
    -webkit-border-top-left-radius: 5px;
    -webkit-border-top-right-radius: 5px;
    -moz-border-radius-topleft: 5px;
    -moz-border-radius-topright: 5px;
     border-top-left-radius: 5px;
     border-top-right-radius: 5px;
}
.panel-info > .panel-heading {
  color: #333;
  background-color:   #e0ffff;
  border-color: #ddd;
}
    </style>
<div class="panel panel-info">
      <div class="panel-heading">
      <h3><left><a href = "#"><img src="./images/compras.png" height="75px" width="75px"></a></left>Listado de Compras</h3>
      </div>
    </div>
    <div class="panel panel-info">
      <div class="input-group"> <span class="input-group-addon "><span class="glyphicon glyphicon-search"></span> Buscar</span>

    <input name="filter" id="filter" type="text" class="form-control" placeholder="¿Qué desea buscar?"></div>
    		<table id="compras" class="table table-striped table-hover display display nowrap">
				<thead>
					<tr>
						<th>ID</th>
						<th>Fecha</th>
						<th>ID Proveedor</th>
						<th>Nº de Factura</th>
						<th>Vendedor</th>
            <th>Total</th>
            <th>ITBMS</th>
            <th>Total bruto</th>
            <th>Acciones</th>
					</tr>
				</thead>
				<tbody class="searchable">
					@foreach($compras as $compra)
						<tr>
							<td>{{ $compra->id }}</td>
							<td>{{ $compra->fecha }}</td>
							<td>{{ $compra->id_proveedor }}</td>
              <td>{{ $compra->num_factura }}</td>
              <td>{{ $compra->nombre_vendedor }}</td>
              <td>{{ $compra->total }}</td>
              <td>{{ $compra->itbms }}</td>
              <td>{{ $compra->total_bruto }}</td>
							<td>
								<a href="{{route('compras.show', $compra->id )}}" data-target="#mostrar" data-toggle="modal" class="label label-info">Ver</a>
				
							</td>
						</tr>
					@endforeach
				</tbody>
			</table>
			<a href="{{URL::to('compras/create')}}"><button class="btn btn-primary" ><span class="glyphicon glyphicon-plus"></span> Agregar compra</button></a>

  	@if(Session::has('message'))
	    <div id="alerta" class="alert alert-{{ Session::get('class') }}">{{ Session::get('message')}}</div>
	@endif

 <!--Modal editar 
<div class="modal fade" id="editar" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Editar compra</h4>
      </div>
      	<div class="modal-body">
       		 
      </div>
      <div class="modal-footer">
      	<input type="submit" value="Guardar" class="btn btn-success"><button class="btn btn-default" data-dismiss="modal">Regresar</button>
		</form>
      </div>
    </div>
  </div>
</div>
 <!--Fin Modal editar -->
 <!--Modal mostrar -->
<div class="modal fade" id="mostrar" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Editar compra</h4>
      </div>
      	<div class="modal-body">
       		 
      </div>
      <div class="modal-footer">
      	<input type="submit" value="Guardar" class="btn btn-success"><button class="btn btn-default" data-dismiss="modal">Regresar</button>
		</form>
      </div>
    </div>
  </div>
</div>
 <!--Fin Modal mostrar -->
    </div>
  </div>
</div>
<script type="text/javascript">
    $(document).ready(function() {
    $('#compras').dataTable({
      
      "dom": 'Rlfrtip',
        "language": {
            "sProcessing":     "Procesando...",
        "sLengthMenu":     "Mostrar _MENU_ registros",
        "sZeroRecords":    "No se encontraron resultados",
        "sEmptyTable":     "Ningún dato disponible en esta tabla",
        "sInfo":           "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
        "sInfoEmpty":      "Mostrando registros del 0 al 0 de un total de 0 registros",
        "sInfoFiltered":   "(filtrado de un total de _MAX_ registros)",
        "sInfoPostFix":    "",
        "sSearch":         "Buscar:",
        "sUrl":            "",
        "sInfoThousands":  ",",
        "sLoadingRecords": "Cargando...",
        "oPaginate": {
            "sFirst":    "Primero",
            "sLast":     "Último",
            "sNext":     "Siguiente",
            "sPrevious": "Anterior"
              },
              }
    } );
    var table = $('#compras').DataTable();
 
  $('#filter').on( 'keyup', function () {
    table.search( this.value ).draw();
  } );
});
</script>
@stop